home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 7
/
Aminet 7 - August 1995.iso
/
Aminet
/
comm
/
net
/
amitcp2_x_gcc.lha
/
RCS.RCSfiles
/
gethostname.c,v
< prev
next >
Wrap
Text File
|
1994-01-12
|
4KB
|
205 lines
head 1.5;
access;
symbols;
locks
jasegler:1.5; strict;
comment @ * @;
1.5
date 94.01.12.18.35.20; author jasegler; state Exp;
branches;
next 1.4;
1.4
date 94.01.11.19.53.25; author jasegler; state Exp;
branches;
next 1.3;
1.3
date 94.01.11.19.21.04; author jasegler; state Exp;
branches;
next 1.2;
1.2
date 94.01.11.19.16.51; author jasegler; state Exp;
branches;
next 1.1;
1.1
date 94.01.11.19.05.28; author jasegler; state Exp;
branches;
next ;
desc
@@
1.5
log
@*** empty log message ***
@
text
@char RCS_ID_GETHOSTNAME_C[] = "$Id: gethostname.c,v 1.4 1994/01/11 19:53:25 jasegler Exp jasegler $";
/*
* gethostname.c -- get host name from the environment variable "HOSTNAME"
*
* Author: jraja <Jarno.Rajahalme@@hut.fi>
*
* Copyright © 1993 AmiTCP/IP Group, <amitcp-group@@hut.fi>
* Helsinki University of Technology, Finland.
* All rights reserved.
*
* Created : Tue Apr 27 17:49:15 1993 jraja
* Last modified: Fri Jun 4 01:58:48 1993 ppessi
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
/****** net.lib/gethostname ******************************************
* NAME
* gethostname -- get the name of the host
*
* SYNOPSIS
* error = gethostname(name, namelen);
*
* int gethostname(char *, int);
*
* FUNCTION
* Get the name of the host to the buffer name of length namelen.
* The name is taken from the environment variable "HOSTNAME"
* where it SHOULD reside.
*
* INPUTS
* name - Pointer to the buffer where the name should be
* stored.
* namelen - Length of the buffer name.
*
* RESULT
* error - 0 on success, -1 in case of an error. The global
* variable errno will be set to indicate the error as
* follows:
*
* ENOENT - The environment variable "HOSTNAME" is not
* found.
*
* EXAMPLE
* char hostname[MAXHOSTNAMELEN];
* int error;
*
* error = gethostname(hostname, sizeof(hostname));
* if (error < 0)
* exit(10);
*
* printf("My name is \"%s\".\n", hostname);
*
* NOTES
* This function is included for source compatibility with Unix
* systems.
* The ENOENT errno value is AmiTCP/IP addition.
*
* BUGS
* Unlike the Unix version, this version assures that the
* resulting string is always NULL-terminated.
*
* SEE ALSO
* getenv()
*****************************************************************************
*
*/
int
gethostname (char *name, int namelen)
{
char Buffer[80];
char *cp = getenv ("HOSTNAME");
if (cp == NULL)
{
errno = ENOENT;
return -1;
}
/* used to use a function called stccpy.. didn't have it but I figured it
does something like this.. :) */
sprintf (Buffer, "%%%ds", namelen);
sprintf (name, Buffer, cp);
free (cp);
return 0;
}
@
1.4
log
@*** empty log message ***
@
text
@d1 1
a1 1
char RCS_ID_C[] = "$Id: gethostname.c,v 1.3 1994/01/11 19:21:04 jasegler Exp jasegler $";
@
1.3
log
@*** empty log message ***
@
text
@d1 1
a1 1
char RCS_ID_C[] = "$Id: gethostname.c,v 1.1 1994/01/11 19:05:28 jasegler Exp jasegler $";
d17 1
@
1.2
log
@*** empty log message ***
@
text
@d84 2
a87 2
printf ("GETHOSTNAME: Buffer %s\n", Buffer);
strcpy (name, cp);
@
1.1
log
@Initial revision
@
text
@d1 1
a1 1
RCS_ID_C = "$Id: gethostname.c,v 1.3 1993/06/03 22:59:38 ppessi Exp $";
d21 2
a22 2
*
* NAME
d43 1
a43 1
* follows:
d47 1
a47 1
*
d51 1
a51 1
*
d55 1
a55 1
*
d73 1
a73 1
int
d76 1
d84 4
a87 1
stccpy (name, cp, namelen);
@